<?php
/**
 * Created by PhpStorm.
 * User: apple
 * Date: 2020/10/18
 * Time: 3:23 PM
 */
namespace app\admin\controller;


use app\admin\logic\AuthLogic;
use app\admin\logic\UserLogic;
use app\BaseController;

use think\App;
use think\facade\Request;

class User extends BaseController
{

    public function __construct()
    {
//        logend(config('user'));
//        if(config('user')['position'] != \app\model\User::SYS_ADMIN)   fail('暂无权限');
    }

    /*
     * 列表
     */
    public function index()
    {
        $userLogic = new UserLogic();
        success($userLogic->getList());
    }
    /*
     * 添加
     */
    public function create()
    {
        $userLogic = new UserLogic();
        success($userLogic->addUser());
    }
    /*
     * 修改
     */
    public function update()
    {
        $userLogic = new UserLogic();
        success($userLogic->updateUser());
    }
    /*
     * 启用或者禁用
     */
    public function del()
    {
        $param = Request::delete();
        if(!isset($param['id']) || empty($param['id']))   fail('请选择人员');
        $id = intval($param['id']);

        $userLogic = new UserLogic();
        success($userLogic->del($id));
    }

    /*
     * 获取用户信息
     */
    public function info()
    {
        $authLogic = new AuthLogic();
        success($authLogic->getAdminInfo());
    }

}